package cn.yto.rocketmq.rocketmqselect.config;


import cn.yto.rocketmq.rocketmqselect.condition.RocketMqTestConditional;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.DeferredImportSelector;
import org.springframework.context.annotation.Import;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.Set;
import java.util.stream.Collectors;

@Conditional(RocketMqTestConditional.class)
@Import(RocketmqLocalTestAutoConfiguration.ImplConfigurationImportSelector.class)
@EnableScheduling
public class RocketmqLocalTestAutoConfiguration {

    static class ImplConfigurationImportSelector implements DeferredImportSelector {

        @Override
        public String[] selectImports(AnnotationMetadata annotationMetadata) {
            Set<Class<?>> configurationBeans = RocketMqTestConfigurations.getSETS();
            String[] imports = new String[configurationBeans.size()];
            Set<String> collect = configurationBeans.stream().map(bean -> RocketMqTestConfigurations.getConfigurationClass(bean)).collect(Collectors.toSet());
            return collect.toArray(imports);
        }
    }



}
